<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=" initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">  
    <link rel="stylesheet" href="../public/lobster/css/public.css" />
    <link rel="stylesheet" href="../public/lobster/css/regsiter.css" />
    <link rel="stylesheet" href="../public/lobster/css/liuzhi.css" />
    <link rel="stylesheet" type="text/css" href="../public/lobster/icon/iconfont.css">
    <script src="../public/lobster/js/lick.js"></script>
    <script src="../public/lobster/js/click.js"></script>
    <title>注册</title>
    <style>
    	#start_reg_inp input {
		    width: 4.8rem!important;
		}
    </style>
</head>   
<body>
<!--主体-表单-->
<div class="reg_logo" style="width:100%;">
    <img src="../public/lobster/images/login.png" alt="" style="width:100%;">
</div>
<div id="start_reg_inp">
    <div class="st_fd_inp st_reg_tel">
        <span class="iconfont icon-shouji"></span> 
        <input id="cid" name="cid" type="text" value="" class="st_reg_tel" onfocus="Focus();" placeholder="手机号" >
        <h4></h4>
    </div>
    <span id="cDiv" ></span>
    <div class="st_fd_inp">
        <span class="iconfont icon-yanzhengma"></span>
        <input id="token" name="token" type="text" value=""  class="st_reg_code" onfocus="Focus();" placeholder="验证码">
        <h4></h4>
        <button id="reg_code" class="reg_code" onclick="testyzm()">获取验证码</button>
    </div>
    <span id="tokenDiv"></span>
    <div class="st_fd_inp">
        <span class="iconfont icon-zhuye1"></span>
        
           <input id="orderCode" name="orderCode" type="text" value=""  class="st_reg_num" onfocus="Focus();"  placeholder="推荐码">
        
       <h4></h4>
    </div>
    <span id="spanOk"></span>
    <div class="st_fd_inp">
        <span class="iconfont icon-mima2"></span>
        <input id="cpwd" name="cpwd" type="password" value="" class="st_reg_ma" onfocus="Focus();" placeholder="请设置密码">
        <h4></h4>
    </div>
    <span id="cpDiv"></span>
    <div class="st_fd_inp">
        <span class="iconfont icon-gou2"></span>
        <input id="crpwd" name="crpwd" type="password" value="" class="st_reg_mato" onfocus="Focus();" placeholder="请确认密码">
        <h4></h4>
    </div>

    <span id="crDiv"></span>
    <input type="hidden" id="oid" name="oid" value="2873"/>
	<input type="hidden" id="uid" name="uid" value=""/>
	<input type="hidden" id="uid" name="openId" value="oaZGYwt5hccFfVhw6cGkNpqMEIso"/>
	<span id="msg"></span>
    <p>*密码为6位数字组成</p>
</div>
<span id="msg"></span>
<!--主体-注册按钮-->
<div id="start_reg_btn">
    <input id="st_reg_btn" type="button" class="st_reg_btn"  value="注册" onclick="frmsubmit()">
   <!--  <div style="margin-top:.2rem;color: #ad0006;font-size:.35rem;">如果已有账号请<a href="" class="r_login_button" style="color: #ad0006;text-decoration:underline!important;font-weight:bold;">登 入</a></div>
 -->
</div>
</body>
<script src="../public/lobster/js/jq-2.1.0.js"></script>
<script src="../public/lobster/js/public.js"></script>
<script src="../public/lobster/js/liuzhi.js"></script>
<script>
    $(function(){
   
       /* 	 liuzhi.open({
       	     title: ['温馨提示']
       	     		 ,anim: 'up'  
	        	     ,content: '520快购商城属于平台模拟测试盘，不存在任何的实际交易行为'
	        	     ,shadeClose: false 
	        	     ,btn: ['确认']
	        	}); */
      
        $("input").focus(function(){
            $("h4").html("");
        });
    })
    
    
    
		var ok = null;
		var phone = /^0?1[3|4|5|7|8][0-9]\d{8}$/;
		//判断是否获取验证码
		var check = 0;	
		if(ok!==null){
			$(document).ready(function(){
				if(ok==false){
					$("#spanOk").html("<font color='red' size='5px'>推荐码错误，请重新输入!</font>");
				}else if(ok==1){
					$("#spanOk").html("<font color='red' size='5px'>推荐码不能为空!</font>");
				}else if(ok==2){
					$("#msg").html("<font color='red' size='5px'>您必须获取验证码后才能进行注册!</font>");
				}
			});
		}
    
		
		 var waitbtn = 10;
		    function countTimebtn() {

		        if (waitbtn == 0) { 		       
		        	$("#st_reg_btn").attr("disabled",false);
		        	$("#st_reg_btn").css("background-color","#c0a065"); 
		          	waitbtn = 10; 
		        } else { 
		        	$("#st_reg_btn").attr("disabled",true); 
		        	$("#st_reg_btn").css("background-color","#ccc"); 
		        	$("#st_reg_btn").text(waitbtn+"秒后可注册");        	
		          waitbtn--; 
		          setTimeout(function() { 
		        	  countTimebtn();
		          }, 
		          1000) 
		        } 
		      }
		
		   

		    
		    
		    
		    

    //立即注册
    function frmsubmit(value)
    {	
    	
	if(waitbtn!=10){
    		return;
    	}
    	countTimebtn();
			if(check==0){
				$("#msg").html("<font color='red' size='4px'>需要获取验证码，才能注册!</font>");
				return;
			}
			 
						
			
			var reg = /^[0-9a-zA-Z]{6,99}$/;
			if(document.getElementById('cid').value.length==0 )
			{
				//alert('您需要完整填写用户名');
				$("#cDiv").html("<font color='red' size='4px'>您需要完整填写用户名!</font>");
				return;
			}
			if(!phone.test(document.getElementById('cid').value))
			{
				
				$("#cDiv").html("<font color='red' size='4px'>手机号码格式错误!</font>");
				return;
			}
			if(document.getElementById('cpwd').value.length==0 )
			{
				//alert('您需要完整填写密码');
				$("#cpDiv").html("<font color='red' size='4px'>您需要完整填写密码!</font>");
				return;
			}
			/*if(document.getElementById('orderCode').value.length==0){
				//alert('您需要完整填写用户推荐编码');
				$("#spanOk").html("<font color='red' size='4px'>您需要完整填写推荐码!</font>");
				return;
			}*/
			if(document.getElementById('cpwd').value.length<6 )
			{
				//alert('为了保证您的账户安全，密码长度不得少于6位！');
				$("#cpDiv").html("<font color='red' size='4px'>为了保证您的账户安全，密码长度不得少于6位!</font>");
				return;
			}
			if(!reg.test(document.getElementById('cpwd').value))
			{
				//alert('密码必须由数字和字母组成');
				$("#cpDiv").html("<font color='red' size='4px'>密码必须由数字和字母组成!</font>");
				return;
			}
			if(document.getElementById('crpwd').value != document.getElementById('cpwd').value )
			{
				//alert('您两次输入的密码不一致');
				$("#crDiv").html("<font color='red' size='4px'>您两次输入的密码不一致!</font>");
				return;
			}
			if(document.getElementById('token').value.length==0 )
			{
				//alert('您必须输入手机短信所接收到的验证码');
				$("#tokenDiv").html("<font color='red' size='4px'>您必须输入手机短信所接收到的验证码!</font>");
				return;
			}
			
			window.location.href = "/reg2.action?username="+document.getElementById('cid').value+"&password="+document.getElementById('cpwd').value+"&repassword="+document.getElementById('crpwd').value+"&token="+document.getElementById('token').value+"&orderCode="+document.getElementById('orderCode').value+"&uid=&oid=2873&openId=oaZGYwt5hccFfVhw6cGkNpqMEIso&_dc"+new Date();

		
		 }
    
    //一分钟倒计时
    var wait = 60;
    function countTime() {

        if (wait == 0) { 
        	$("#reg_code").attr("disabled",false);
        	$("#reg_code").text("获取验证码"); 
          	wait = 60; 
        } else { 
        	$("#reg_code").attr("disabled",true); 
        	$("#reg_code").text(wait+"秒后可再发送"); 
          wait--; 
          setTimeout(function() { 
        	  countTime();
          }, 
          1000) 
        } 
      } 
    
    //获取验证码
    function testyzm()
	{	
    	if(wait!=60){
    		return;
    	}

		check = 1;
		if(!phone.test(document.getElementById('cid').value))
		{
			//alert('您需要完整填写用户名');
			$("#cDiv").html("<font color='red' size='4px'>手机号码格式错误!</font>");
			return;
		}
		if(document.getElementById('cid').value)
		{
			$.post('sendmsg',{phone:document.getElementById('cid').value},function(data){
				if(data.success)
				{	
					countTime();
					// alert('验证码已经发送，请接收后填写，并提交注册。');
					//$.messager.alert("提示信息", "验证码已经发送，请接收后填写，并提交注册。");
					$("#msg").html("<font color='red' size='4px'>验证码已经发送，请接收后填写，并提交注册。</font>");
				}else
				{
					//alert(data.msg);
					$("#msg").html("<font color='red' size='4px'>"+data.msg+"</font>");
				}
			}, "json");
		}
		else
		{
			//alert("您必须完整填写注册手机后再获取验证码。");
			$("#cDiv").html("<font color='red' size='4px'>您必须完整填写注册手机后再获取验证码!</font>");
			return;
		}
	}
    
    function Focus(){
		$("#cDiv").html("");
		$("#cpDiv").html("");
		$("#crDiv").html("");
		$("#spanOk").html("");
		$("#tokenDiv").html("");
		$("#msg").html("");
	}
    
    //提交验证
    /* function success(){
            if(frmtel("#st_reg_tel")&&noempty('.st_reg_code')&&frmpwd('.st_reg_ma')&&againpwd(".st_reg_mato",'.st_reg_ma')){
                window.location.href="index.html";
            }
    } */
</script>
</html>
